#ifndef __SOCK_UTILS_H
#define __SOCK_UTILS_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <sys/fcntl.h>

#include <netdb.h>
#define __GNU_SOURCE

void error_msg(const char *msg);
void info(const char *msg);

int create_socket(sa_family_t type);
int create_tcp_socket();
int create_udp_socket();

int create_tcp_server_socket(char *port, int qlen);
int bind_and_listen(int fd, in_port_t port, int qlen);

int connect_to_tcp_server(int fd, char *server, char *port);
int connect_to_udp_server(int fd, char *server, in_port_t port);

int make_socket_nonblocking(int fd);

#endif
